package cn.edu.ecut.scheduling;

public class ShareTest {
	
	public static void main(String[] args) throws InterruptedException {
		
		Runnable share = new Runnable() {
			
			private int counter ; // 为匿名内部类声明一个int类型的实例变量
			
			@Override
			public void run() {
				for( int i = 0 ; i < 10 ; i++ ) {
					counter++ ;
				}
			}
			
			public String toString() {
				return "counter = " + counter ;
			}
			
		};
		
		Thread first = new Thread( share , "first" );
		Thread second = new Thread( share , "second" );
		Thread third = new Thread( share , "third" );
		
		first.start();
		second.start();
		third.start();
		
		Thread.sleep( 100 );
		
		System.out.println( share );
	}

}
